list-[id].vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <template>
  2. <div id="newsList">
  3. <!-- 页面头部 -->
  4. <HomePageHead></HomePageHead>
  5. <!-- 导航栏 -->
  6. <HomePageNavigation></HomePageNavigation>
  7. <!-- 二级标题-->
  8. <!--<div class="sannongzhichuang" v-if="parent_name != ''">
  9. <div class="inner">
  10. <h2>
  11. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  12. <em class="iconfont icon-xingzhuang-zhijiaosanjiaoxing-copy"></em>
  13. </h2>
  14. <p class="introduction">
  15. <strong>频道介绍</strong>
  16. <div v-for="(item, index) in secondNav" :key="index">
  17. <span v-if="index <= 7">
  18. <NuxtLink :to="{ path: `/${item.aLIas_pinyin}/list-1.html`}">{{ item.alias }}</NuxtLink>
  19. </span>
  20. <b v-else></b>
  21. </div>
  22. </p>
  23. </div>
  24. </div>-->
  25. <!-- 面包屑导航 -->
  26. <div class="breadcrumb-box">
  27. <div class="inner">
  28. <span class="location">当前位置:</span>
  29. <el-breadcrumb :separator-icon="ArrowRight">
  30. <el-breadcrumb-item>
  31. <NuxtLink to="/">首页</NuxtLink>
  32. </el-breadcrumb-item>
  33. <el-breadcrumb-item v-if="parent_name != ''">
  34. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  35. </el-breadcrumb-item>
  36. <el-breadcrumb-item>{{ name }}</el-breadcrumb-item>
  37. </el-breadcrumb>
  38. </div>
  39. </div>
  40. <!-- 资讯列表 -->
  41. <div class="newsList">
  42. <div class="listBox">
  43. <div class="listBoxLeft">
  44. <ul class="list">
  45. <li v-for="(item, index) in newsList" :key="index">
  46. <NuxtLink :href="getLinkPathDetail(item)" :title="item.alias">
  47. <div class="li_img_box" v-if="index % 2 == 0">
  48. <img class="" src="http://img.fazdyzx.org.cn/202601/5c9d396e14a53bb.png" title=""
  49. alt="">
  50. </div>
  51. <div class="li_right_box">
  52. <h4 class="li_h4_dot1">{{ item.title }}</h4>
  53. <div class="li_dot3">
  54. {{ item.title }}
  55. </div>
  56. </div>
  57. </NuxtLink>
  58. </li>
  59. </ul>
  60. <!-- 分页器 -->
  61. <div class="pagination" v-if="total > 0">
  62. <el-pagination size="small" background layout="prev, pager, next" :total="total" class="mt-4"
  63. :page-size="pageSize" :current-page="pageNum" prev-text="上一页" next-text="下一页"
  64. @current-change="changePage" />
  65. <span class="total">共{{ total }}条</span>
  66. </div>
  67. </div>
  68. <div class="listBoxRight">
  69. <!-- <DetailHotNews></DetailHotNews> -->
  70. <DetailHotNews2></DetailHotNews2>
  71. </div>
  72. </div>
  73. </div>
  74. <!-- 页面底部 -->
  75. <HomeFoot></HomeFoot>
  76. </div>
  77. </template>
  78. <script setup>
  79. //1.页面必备依赖 start ---------------------------------------->
  80. import { ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus'
  81. import { ArrowRight } from '@element-plus/icons-vue'
  82. import { ref, onMounted } from 'vue';
  83. //当前列表名称
  84. const name = ref('')
  85. const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()
  86. //格式化跳转路径
  87. const getLinkPathDetail = (item) => {
  88. if (item.islink == 1) {
  89. return `${item.linkurl}`;
  90. } else {
  91. //return `/${item.aLIas_pinyin}/${item.id}`;
  92. //return `/newsDetail/${item.id}`
  93. return `/${item.pinyin}/${item.id}.html`;
  94. }
  95. }
  96. //1.页面必备依赖 end ---------------------------------------->
  97. //1.获得路由id start ---------------------------------------->
  98. const route = useRoute();
  99. let articleId = 0;//路由id
  100. let pageNum = ref(2);
  101. let total = ref(1);
  102. let pageSize = ref(10);
  103. //获得当前的完整路径
  104. const fullPath = route.path;
  105. //拆分,取出来中间这一段,然后提取数字部分
  106. const segments = fullPath.split('/');
  107. const targetSegment = segments[1];
  108. //const numberPart = targetSegment.match(/\d+$/)?.[0];
  109. //let routeId = 20 //排除路径错误可以打开这个
  110. //通过导航路径反向查询导航id
  111. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  112. method: 'GET',
  113. query: {
  114. 'pinyin': targetSegment,
  115. },
  116. });
  117. if (getRouteId.code == 200) {
  118. articleId = getRouteId.data.category_id
  119. } else {
  120. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  121. console.log("错误位置:通过url路径查询导航池id")
  122. console.log("后端错误反馈:", getRouteId.message)
  123. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  124. }
  125. //获得html前的数字
  126. // const pageUrl = segments[2];
  127. // const pageNumber = pageUrl.split('.')[0];
  128. // console.log("当前URL中的页码:")
  129. // console.log(pageNumber)//2
  130. // pageNum.value = parseInt(pageNumber);
  131. pageNum.value = parseInt(route.params.id);
  132. //1.获得路由id end ---------------------------------------->
  133. //2.页面数据 start ---------------------------------------->
  134. //2.2新闻列表
  135. const newsList = ref([]);
  136. let newslists = async () => {
  137. const listData = await requestDataPromise('/web/getWebsiteArticleList', {
  138. method: 'GET',
  139. query: {
  140. 'page': pageNum.value,
  141. 'pageSize': pageSize.value,
  142. 'catid': articleId
  143. },
  144. });
  145. if (listData.code == 200) {
  146. newsList.value = listData.data.rows;
  147. total.value = listData.data.count;
  148. } else {
  149. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  150. // console.log("错误位置:获取新闻列表")
  151. // console.log("后端错误反馈:", listData.message)
  152. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  153. }
  154. }
  155. //获得列表
  156. newslists();
  157. //分页事件
  158. let changePage = (value) => {
  159. console.log("当前页码", value);
  160. navigateTo(`/${targetSegment}/list-${value}.html`)
  161. }
  162. //2.3获得页面名称
  163. let getPageName = async () => {
  164. const pageName = await requestDataPromise('/web/getOneWebsiteCategory', {
  165. method: 'GET',
  166. query: {
  167. 'catid': articleId
  168. },
  169. });
  170. if (pageName.code == 200) {
  171. name.value = pageName.data.alias
  172. } else {
  173. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  174. // console.log("错误位置:设置页面标题")
  175. // console.log("后端错误反馈:", pageName.message)
  176. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  177. }
  178. }
  179. //获得列表
  180. getPageName();
  181. //2.页面数据 end ---------------------------------------->
  182. //3.二级栏目 start ---------------------------------------->
  183. //3.1通过id获取父栏目
  184. const parent_name = ref([]);
  185. const parent_id = ref([]);
  186. const parent_pinyin = ref("");
  187. let getParentNav = async () => {
  188. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  189. method: 'GET',
  190. query: {
  191. 'catid': articleId
  192. },
  193. });
  194. if (listData.code == 200) {
  195. console.log(111999)
  196. console.log(listData.data);
  197. parent_name.value = listData.data.parent_name;
  198. parent_id.value = listData.data.parent_id;
  199. parent_pinyin.value = listData.data.parent_pinyin;
  200. } else {
  201. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  202. // console.log("错误位置:获取新闻列表")
  203. // console.log("后端错误反馈:", listData.message)
  204. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  205. }
  206. getSecondNav();
  207. }
  208. //获得列表
  209. getParentNav();
  210. // 3.2获取二级栏目
  211. const secondNav = ref([]);
  212. let getSecondNav = async () => {
  213. const listData = await requestDataPromise('/web/getWebsiteModelCategory', {
  214. method: 'GET',
  215. query: {
  216. 'placeid': 1,
  217. 'pid': parent_id.value,
  218. 'num': 8,
  219. },
  220. });
  221. console.log('listData', listData);
  222. if (listData.code == 200) {
  223. secondNav.value = listData.data
  224. } else {
  225. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  226. console.log("错误位置:获取新闻列表")
  227. console.log("后端错误反馈:", listData.message)
  228. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  229. }
  230. }
  231. //3.二级栏目 end ---------------------------------------->
  232. //4.设置seo信息 start---------------------------------------->
  233. //4.1 设置seo信息
  234. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  235. method: 'GET',
  236. query: {
  237. 'catid': articleId
  238. },
  239. });
  240. if (setData.code == 200) {
  241. let seoTitle = setData.data.seo_title;
  242. let seoDescription = setData.data.seo_description;
  243. let seoKeywords = setData.data.seo_keywords;
  244. let seoSuffix = setData.data.suffix;
  245. let seoName = setData.data.website_name;
  246. useSeoMeta({
  247. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  248. meta: [
  249. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  250. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  251. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no', tagPriority: 10 }
  252. ]
  253. });
  254. } else {
  255. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  256. // console.log("错误位置:设置列表页面SEO数据")
  257. // console.log("后端错误反馈:", setData.message)
  258. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  259. }
  260. //4.设置seo信息 end---------------------------------------->
  261. //5.广告 start---------------------------------------->
  262. let adImg1 = ref({});
  263. let adImg2 = ref({});
  264. onMounted(async () => {
  265. //从客户端获取行政职能部门 加快打开速度
  266. const { $webUrl, $CwebUrl } = useNuxtApp();
  267. //广告1
  268. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_list_0001`
  269. const responseAd1 = await fetch(url, {
  270. headers: {
  271. 'Content-Type': 'application/json',
  272. 'Userurl': $CwebUrl,
  273. 'Origin': $CwebUrl
  274. }
  275. });
  276. const resultAd1 = await responseAd1.json();
  277. adImg1.value = resultAd1.data[0];
  278. //广告2
  279. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_list_0002`
  280. const responseAd2 = await fetch(url2, {
  281. headers: {
  282. 'Content-Type': 'application/json',
  283. 'Userurl': $CwebUrl,
  284. 'Origin': $CwebUrl
  285. }
  286. });
  287. const resultAd2 = await responseAd2.json();
  288. adImg2.value = resultAd2.data[0];
  289. })
  290. //5.广告 end---------------------------------------->
  291. </script>
  292. <style lang="less" scoped>
  293. // @import url('@/assets/css/list/pc.less');
  294. // @import url('@/assets/css/list/yd.less');
  295. //面包屑
  296. .breadcrumb-box {
  297. width: 1400px;
  298. margin: 0 auto;
  299. .inner {
  300. width: 100%;
  301. height: 22px;
  302. margin-top: 20px;
  303. margin-bottom: 20px;
  304. font-family: Microsoft YaHei, Microsoft YaHei;
  305. font-weight: 400;
  306. font-size: 20px;
  307. color: #666666;
  308. line-height: 23px;
  309. text-align: left;
  310. font-style: normal;
  311. text-transform: none;
  312. display: flex;
  313. align-items: center;
  314. border-bottom: 1px dashed #ccc;
  315. margin-bottom: 10px;
  316. padding: 20px 20px 20px 0;
  317. box-sizing: border-box;
  318. a {
  319. font-size: 16px;
  320. color: #000;
  321. line-height: 20px;
  322. }
  323. span {
  324. font-size: 16px;
  325. color: #000;
  326. line-height: 20px;
  327. &.location {
  328. line-height: 20px;
  329. }
  330. }
  331. }
  332. }
  333. //资讯列表
  334. .newsList {
  335. width: 1400px;
  336. margin: 0 auto;
  337. .listBox {
  338. display: flex;
  339. align-items: flex-start;
  340. justify-content: space-between;
  341. .listBoxLeft {
  342. width: 1030px;
  343. .list {
  344. >li {
  345. width: 100%;
  346. height: auto;
  347. overflow: hidden;
  348. border-bottom: 1px dashed #ccc;
  349. margin-top: 30px;
  350. padding-bottom: 30px;
  351. a {
  352. color: #337ab7;
  353. }
  354. p {
  355. a {
  356. width: 100%;
  357. height: 72px;
  358. line-height: 24px;
  359. overflow: hidden;
  360. font-size: 14px;
  361. color: #666;
  362. font-weight: normal;
  363. }
  364. }
  365. }
  366. }
  367. }
  368. .listBoxRight {
  369. width: 315px;
  370. overflow: hidden;
  371. }
  372. }
  373. }
  374. //分页
  375. .pagination {
  376. height: 34px;
  377. display: flex;
  378. justify-content: center;
  379. margin: 0;
  380. width: 100%;
  381. overflow: hidden;
  382. margin: 20px 0;
  383. padding: 20px 0;
  384. // 鼠标移入后字体颜色
  385. .el-pagination::v-deep :hover {
  386. color: #139609;
  387. }
  388. .el-pagination.is-background::v-deep .btn-next,
  389. .el-pagination.is-background::v-deep .btn-prev {
  390. width: 70px;
  391. height: 34px;
  392. margin: 0px 10px;
  393. border-radius: 4px;
  394. }
  395. .el-pagination.is-background::v-deep .el-pager li {
  396. margin: 0px 10px;
  397. width: 38px;
  398. height: 34px;
  399. border-radius: 4px;
  400. }
  401. .el-pagination.is-background::v-deep .btn-next.is-active,
  402. .el-pagination.is-background::v-deep .btn-prev.is-active,
  403. .el-pagination.is-background::v-deep .el-pager li.is-active {
  404. background-color: #337ab7;
  405. color: #fff;
  406. }
  407. .total {
  408. display: block;
  409. height: 34px;
  410. line-height: 34px;
  411. font-size: 18px;
  412. margin-left: 20px;
  413. }
  414. }
  415. .breadcrumb-box {
  416. width: 1400PX;
  417. margin: 0px auto 0px;
  418. }
  419. .el-breadcrumb {
  420. height: 22PX;
  421. line-height: 22PX;
  422. }
  423. .breadcrumb-box .inner span.location {
  424. font-size: 16PX;
  425. ;
  426. height: 22PX;
  427. ;
  428. line-height: 22PX;
  429. font-weight: normal;
  430. }
  431. .breadcrumb-box .inner a {
  432. font-size: 16PX;
  433. ;
  434. height: 22PX;
  435. line-height: 22PX;
  436. display: inline-block;
  437. font-weight: normal;
  438. }
  439. .breadcrumb-box .phone_breadcrumb_text /deep/.el-breadcrumb__inner {
  440. font-size: 16PX;
  441. ;
  442. height: 22PX;
  443. line-height: 22PX;
  444. font-weight: normal;
  445. }
  446. .breadcrumb-box:deep(.el-icon) {
  447. width: 16PX;
  448. height: 16PX;
  449. }
  450. .breadcrumb-box .inner span {
  451. font-size: 16PX;
  452. ;
  453. height: 22PX;
  454. line-height: 22PX;
  455. }
  456. .newsList {
  457. width: 1400PX;
  458. box-sizing: border-box;
  459. }
  460. .newsList .listBox {
  461. display: block;
  462. width: 100%;
  463. overflow: hidden;
  464. }
  465. .newsList .listBox .listBoxLeft {
  466. float: left;
  467. width: 64%;
  468. overflow: hidden;
  469. }
  470. .newsList .listBox .listBoxRight {
  471. float: right;
  472. width: 33%;
  473. overflow: hidden;
  474. }
  475. .newsList .listBox .listBoxLeft .list>li {
  476. display: block;
  477. margin-top: 22PX;
  478. padding-bottom: 22PX;
  479. }
  480. .li_img_box {
  481. float: left;
  482. width: 160PX;
  483. height: 110PX;
  484. margin-right: 11px;
  485. }
  486. .li_img_box * {
  487. display: block;
  488. width: 100%;
  489. height: 100%;
  490. }
  491. .li_right_box {}
  492. .li_h4_dot1 {
  493. height: 22PX;
  494. line-height: 22PX;
  495. font-size: 20PX;
  496. font-weight: bold;
  497. color: #333;
  498. margin-top: 8PX;
  499. display: block;
  500. word-break: keep-all;
  501. white-space: nowrap;
  502. overflow: hidden;
  503. text-overflow: ellipsis;
  504. }
  505. .li_dot3 {
  506. height: 72PX;
  507. line-height: 24PX;
  508. font-size: 14PX;
  509. color: #333;
  510. font-weight: normal;
  511. margin-top: 4px;
  512. overflow: hidden;
  513. display: -webkit-box !important;
  514. -webkit-box-orient: vertical;
  515. -webkit-line-clamp: 3;
  516. }
  517. .newsList .listBox .listBoxLeft .list>li a {
  518. display: block;
  519. width: 100%;
  520. height: auto;
  521. overflow: hidden;
  522. }
  523. .pagination {
  524. padding: 10px 0px;
  525. margin: 10px 0px;
  526. }
  527. //分页
  528. .pagination {
  529. height: 34PX;
  530. display: flex;
  531. justify-content: center;
  532. margin: 0;
  533. width: 100%;
  534. overflow: hidden;
  535. margin: 20PX 0;
  536. padding: 20PX 0;
  537. // 鼠标移入后字体颜色
  538. .el-pagination::v-deep :hover {
  539. color: #139609;
  540. }
  541. .el-pagination.is-background::v-deep .btn-next,
  542. .el-pagination.is-background::v-deep .btn-prev {
  543. width: 70PX;
  544. height: 34PX;
  545. margin: 0px 10PX;
  546. border-radius: 4PX;
  547. }
  548. .el-pagination.is-background::v-deep .el-pager li {
  549. margin: 0px 10PX;
  550. width: 38PX;
  551. height: 34PX;
  552. border-radius: 4PX;
  553. }
  554. .el-pagination.is-background::v-deep .btn-next.is-active,
  555. .el-pagination.is-background::v-deep .btn-prev.is-active,
  556. .el-pagination.is-background::v-deep .el-pager li.is-active {
  557. background-color: #337ab7;
  558. color: #fff;
  559. }
  560. .total {
  561. display: block;
  562. height: 34PX;
  563. line-height: 34PX;
  564. font-size: 18PX;
  565. margin-left: 20PX;
  566. }
  567. }
  568. @media screen and (min-width: 1401px) {
  569. //你的样式
  570. }
  571. @media screen and (max-width: 1400px) {
  572. .breadcrumb-box {
  573. width: 100%;
  574. margin: 0px auto 0px;
  575. box-sizing: border-box;
  576. padding: 0px 10px;
  577. }
  578. .newsList {
  579. width: 100%;
  580. box-sizing: border-box;
  581. padding: 0px 10px;
  582. margin: 0px auto 0px;
  583. }
  584. }
  585. @media screen and (min-width: 801px) and (max-width: 1400px) {
  586. //你的样式
  587. }
  588. @media screen and (max-width: 800px) {
  589. //你的样式
  590. .listBoxLeft {
  591. width: 100% !important;
  592. float: none !important;
  593. }
  594. .listBoxRight {
  595. width: 100% !important;
  596. float: none !important;
  597. }
  598. .el-pagination.is-background::v-deep .btn-next,
  599. .el-pagination.is-background::v-deep .btn-prev {
  600. width: 60PX !important;
  601. height: 34PX !important;
  602. margin: 0px 2PX !important;
  603. }
  604. .el-pagination.is-background::v-deep .el-pager li {
  605. margin: 0px 2PX !important;
  606. width: 34PX !important;
  607. height: 34PX !important;
  608. }
  609. .breadcrumb-box :deep(.el-icon) {}
  610. .breadcrumb-box .inner span.location,
  611. .breadcrumb-box .inner span {
  612. font-size: 24px;
  613. }
  614. .breadcrumb-box .inner a {
  615. font-size: 24px;
  616. height: 55px;
  617. line-height: 55px;
  618. }
  619. .breadcrumb-box .phone_breadcrumb_text :deep(.el-breadcrumb__inner) {
  620. font-size: 24px;
  621. height: 55px;
  622. line-height: 55px;
  623. }
  624. .li_img_box {
  625. width: 222px;
  626. height: 144px;
  627. margin-right: 11px;
  628. }
  629. .newsList .listBox .listBoxLeft .list>li {
  630. margin-top: 22px;
  631. padding-bottom: 22px;
  632. }
  633. .li_h4_dot1 {
  634. height: 44px;
  635. line-height: 44px;
  636. font-size: 30px;
  637. margin-top: 8px;
  638. }
  639. .li_dot3 {
  640. max-height: 99px;
  641. height: auto;
  642. line-height: 33px;
  643. font-size: 24px;
  644. margin-top: 4px;
  645. }
  646. }
  647. </style>